<script setup>
import { ref,watch } from 'vue'
import {_addExhibition} from "../../http/api.js";
import {ElMessage} from "element-plus";
const props = defineProps({
  showExhibition: Boolean
})
const $emit = defineEmits(['showExhibitionEmit'])
watch(() => props.showExhibition,(val) => {
  showExhibition.value = val;
})
const showExhibition = ref(false);
const fairName = ref('');

//添加展会
const addExhibition = () => {
  if(!fairName.value) return ElMessage({message: '请输入展会名称', type: 'warning' });
  let params = {
    fairName: fairName.value
  }
  _addExhibition(params)
      .then(res => {
        console.log(res);
        if(res.data.ok) {
          ElMessage({message: '添加成功', type: 'success' });
          showExhibition.value = false;
          $emit('showExhibitionEmit',false)
        }
      })
      .catch(err => {
        console.log(err);
      })
}
</script>

<template>
  <el-dialog v-model="showExhibition" title="添加展会" width="800">
    <div>
      <p style="margin-bottom: 10px">请输入展会名称</p>
      <el-input v-model="fairName"></el-input>
    </div>
    <div style="margin-top: 20px">
      <el-button type="primary" @click="addExhibition">提交</el-button>
    </div>
  </el-dialog>
</template>

<style scoped lang="scss">

</style>